package com.wy.common.flutter

import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import com.wy.common.R
import com.wy.common.base.BaseFragment

//import kotlinx.android.synthetic.main.fragment_flutter.*

class WFlutterFragment :BaseFragment(){

//    protected lateinit var flutterEngine : FlutterEngine
//    protected var flutterView : FlutterView? = null
//
    override fun getLayoutId(): Int {
        return R.layout.fragment_flutter
    }
//
//    override fun onAttach(context: Context) {
//        super.onAttach(context)
//        //初始化 flutter 引擎
//        flutterEngine = FlutterEngine(context)
//        //创建flutter相关的代码和模块,执行dart代码
//        flutterEngine.dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
//    }
//
//    fun setTitle(title : String){
//        tvTitle.text = title
//    }
//
//    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
//        super.onViewCreated(view, savedInstanceState)
//        (layoutView as ViewGroup).addView(createFlutterView(activity!!))
//    }
//
//    private fun createFlutterView(context: Context):FlutterView{
//        //使用 FlutterTextureVie来进行渲染,避免FlutterSurfaceView从后台返回后页面被复用问题
//        val flutterTextureView : FlutterTextureView = FlutterTextureView(activity!!)
//        flutterView = FlutterView(context,flutterTextureView)
//        return flutterView!!
//    }
//
//    /**
//     * 配置生命周期
//     */
//    override fun onStart() {
//        flutterView!!.attachToFlutterEngine(flutterEngine)
//        super.onStart()
//    }
//
//    override fun onResume() {
//        super.onResume()
//        //flutter >= 1.17
//        flutterEngine.lifecycleChannel.appIsResumed()
//    }
//
//    override fun onPause() {
//        super.onPause()
//        flutterEngine.lifecycleChannel.appIsInactive()
//    }
//
//    override fun onStop() {
//        super.onStop()
//        flutterEngine.lifecycleChannel.appIsPaused()
//    }
//
//    override fun onDestroy() {
//        super.onDestroy()
//        flutterEngine.lifecycleChannel.appIsDetached()
//    }

}